home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / source / amiga / Locale.mod < prev    next >
Text File  |  1995-06-29  |  14KB  |  430 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: Locale.mod $
  4.   Description: Interface to locale.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.7 $
  8.       $Author: fjc $
  9.         $Date: 1995/06/04 23:13:14 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1991-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A Interface Copyright © 1994-1995, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. *************************************************************************)
  21.  
  22. <* STANDARD- *>
  23.  
  24. MODULE [2] Locale;
  25.  
  26. IMPORT
  27.   SYS := SYSTEM, Kernel, e := Exec, u := Utility, d := Dos, s := Sets;
  28.  
  29. (*
  30. **      $VER: locale.h 38.12 (24.2.93)
  31. **
  32. **      locale.library interface structures and definitions
  33. *)
  34.  
  35. (*****************************************************************************)
  36.  
  37. CONST
  38.  
  39. (* constants for GetLocaleStr() *)
  40.   day1 * = 1;           (* Sunday    *)
  41.   day2 * = 2;           (* Monday    *)
  42.   day3 * = 3;           (* Tuesday   *)
  43.   day4 * = 4;           (* Wednesday *)
  44.   day5 * = 5;           (* Thursday  *)
  45.   day6 * = 6;           (* Friday    *)
  46.   day7 * = 7;           (* Saturday  *)
  47.  
  48.   abday1 * = 8;         (* Sun *)
  49.   abday2 * = 9;         (* Mon *)
  50.   abday3 * = 10;        (* Tue *)
  51.   abday4 * = 11;        (* Wed *)
  52.   abday5 * = 12;        (* Thu *)
  53.   abday6 * = 13;        (* Fri *)
  54.   abday7 * = 14;        (* Sat *)
  55.  
  56.   mon1 * = 15;          (* January   *)
  57.   mon2 * = 16;          (* February  *)
  58.   mon3 * = 17;          (* March     *)
  59.   mon4 * = 18;          (* April     *)
  60.   mon5 * = 19;          (* May       *)
  61.   mon6 * = 20;          (* June      *)
  62.   mon7 * = 21;          (* July      *)
  63.   mon8 * = 22;          (* August    *)
  64.   mon9 * = 23;          (* September *)
  65.   mon10 * = 24;         (* October   *)
  66.   mon11 * = 25;         (* November  *)
  67.   mon12 * = 26;         (* December  *)
  68.  
  69.   abmon1 * = 27;        (* Jan *)
  70.   abmon2 * = 28;        (* Feb *)
  71.   abmon3 * = 29;        (* Mar *)
  72.   abmon4 * = 30;        (* Apr *)
  73.   abmon5 * = 31;        (* May *)
  74.   abmon6 * = 32;        (* Jun *)
  75.   abmon7 * = 33;        (* Jul *)
  76.   abmon8 * = 34;        (* Aug *)
  77.   abmon9 * = 35;        (* Sep *)
  78.   abmon10 * = 36;       (* Oct *)
  79.   abmon11 * = 37;       (* Nov *)
  80.   abmon12 * = 38;       (* Dec *)
  81.  
  82.   yesStr * = 39;        (* affirmative response for yes/no queries *)
  83.   noStr * = 40;         (* negative response for yes/no queries    *)
  84.  
  85.   amStr * = 41;         (* AM *)
  86.   pmStr * = 42;         (* PM *)
  87.  
  88.   softHyphen * = 43;    (* soft hyphenation *)
  89.   hardHyphen * = 44;    (* hard hyphenation *)
  90.  
  91.   openQuote * = 45;     (* start of quoted block *)
  92.   closeQuote * = 46;    (* end of quoted block   *)
  93.  
  94.   yesterdaystr * = 47;  (* Yesterday *)
  95.   todaystr * = 48;      (* Today     *)
  96.   tomorrowstr * = 49;   (* Tomorrow  *)
  97.   futurestr * = 50;     (* Future    *)
  98.  
  99.   maxStrMsg * = 51;     (* current number of defined strings *)
  100.  
  101.  
  102. (*****************************************************************************)
  103.  
  104. TYPE
  105.  
  106. (* OpenLibrary("locale.library",0) returns a pointer to this structure *)
  107.   LocaleBasePtr* = POINTER TO LocaleBase;
  108.   LocaleBase * = RECORD (e.LibraryBase)
  109.     libNode *    : e.Library;
  110.     sysPatches - : BOOLEAN;     (* TRUE if locale installed its patches *)
  111.   END;
  112.  
  113.  
  114. (*****************************************************************************)
  115.  
  116. TYPE
  117.  
  118. (* This structure must only be allocated by locale.library and is READ-ONLY! *)
  119.  
  120.   LocalePtr * = POINTER TO Locale;
  121.   Locale * = RECORD
  122.     localeName -       : e.LSTRPTR;   (* locale's name               *)
  123.     languageName -     : e.LSTRPTR;   (* language of this locale     *)
  124.     prefLanguages -    : ARRAY 10 OF e.LSTRPTR; (* preferred languages*)
  125.     flags -            : s.SET32;     (* always 0 for now            *)
  126.  
  127.     codeSet -          : e.ULONG;     (* always 0 for now            *)
  128.     countryCode -      : e.ULONG;     (* user's country code         *)
  129.     telephoneCode -    : e.ULONG;     (* country's telephone code    *)
  130.     gmtOffset -        : LONGINT;     (* minutes from GMT            *)
  131.     measuringSystem -  : SHORTINT;    (* what measuring system?      *)
  132.     calendarType -     : SHORTINT;    (* what calendar type?         *)
  133.     reserved0 -        : ARRAY 2 OF SHORTINT;
  134.  
  135.     dateTimeFormat -   : e.LSTRPTR;    (* regular date & time format  *)
  136.     dateFormat -       : e.LSTRPTR;    (* date format by itself       *)
  137.     timeFormat -       : e.LSTRPTR;    (* time format by itself       *)
  138.  
  139.     shortDateTimeFormat - : e.LSTRPTR; (* short date & time format    *)
  140.     shortDateFormat -  : e.LSTRPTR;    (* short date format by itself *)
  141.     shortTimeFormat -  : e.LSTRPTR;    (* short time format by itself *)
  142.  
  143.     (* for numeric values *)
  144.     decimalPoint -     : e.LSTRPTR;    (* character before the decimals *)
  145.     groupSeparator -   : e.LSTRPTR;    (* separates groups of digits    *)
  146.     fracGroupSeparator - : e.LSTRPTR;  (* separates groups of digits    *)
  147.     grouping -         : e.ADDRESS;    (* size of each group            *)
  148.     fracGrouping -     : e.ADDRESS;    (* size of each group            *)
  149.  
  150.     (* for monetary values *)
  151.     monDecimalPoint -  : e.LSTRPTR;
  152.     monGroupSeparator - : e.LSTRPTR;
  153.     monFracGroupSeparator - : e.LSTRPTR;
  154.     monGrouping -      : e.ADDRESS;
  155.     monFracGrouping -  : e.ADDRESS;
  156.     monFracDigits -    : SHORTINT;     (* digits after the decimal point   *)
  157.     monIntFracDigits - : SHORTINT;     (* for international representation *)
  158.     reserved1 -        : ARRAY 2 OF SHORTINT;
  159.  
  160.     (* for currency symbols *)
  161.     monCS -            : e.LSTRPTR;    (* currency symbol              *)
  162.     monSmallCS -       : e.LSTRPTR;    (* symbol for small amounts     *)
  163.     monIntCS -         : e.LSTRPTR;    (* internationl (ISO 4217) code *)
  164.  
  165.     (* for positive monetary values *)
  166.     monPositiveSign -  : e.LSTRPTR;    (* indicate positive money value   *)
  167.     monPositiveSpaceSep - : SHORTINT;  (* determine if separated by space *)
  168.     monPositiveSignPos - : SHORTINT;   (* position of positive sign       *)
  169.     monPositiveCSPos - : SHORTINT;     (* position of currency symbol     *)
  170.     reserved2 -        : SHORTINT;
  171.  
  172.     (* for negative monetary values *)
  173.     monNegativeSign -  : e.LSTRPTR;    (* indicate negative money value   *)
  174.     monNegativeSpaceSep - : SHORTINT;  (* determine if separated by space *)
  175.     monNegativeSignPos - : SHORTINT;   (* position of negative sign       *)
  176.     monNegativeCSPos - : SHORTINT;     (* position of currency symbol     *)
  177.     reserved3 -        : SHORTINT;
  178.   END;
  179.  
  180. CONST
  181.  
  182. (* constants for Locale.loc_MeasuringSystem *)
  183.   iso *      = 0;             (* international metric system *)
  184.   american * = 1;             (* american system             *)
  185.   imperial * = 2;             (* imperial system             *)
  186.   british *  = 3;             (* british system              *)
  187.  
  188. (* constants for Locale.loc_CalendarType *)
  189.   ct7sun * = 0;      (* 7 days a week, Sunday is the first day    *)
  190.   ct7mon * = 1;      (* 7 days a week, Monday is the first day    *)
  191.   ct7tue * = 2;      (* 7 days a week, Tuesday is the first day   *)
  192.   ct7wed * = 3;      (* 7 days a week, Wednesday is the first day *)
  193.   ct7thu * = 4;      (* 7 days a week, Thursday is the first day  *)
  194.   ct7fri * = 5;      (* 7 days a week, Friday is the first day    *)
  195.   ct7sat * = 6;      (* 7 days a week, Saturday is the first day  *)
  196.  
  197. (* constants for Locale.loc_MonPositiveSpaceSep and Locale.loc_MonNegativeSpaceSep *)
  198.   nospace * = 0; (* cur. symbol is NOT separated from value with a space *)
  199.   space *   = 1; (* cur. symbol IS separated from value with a space     *)
  200.  
  201. (* constants for Locale.loc_MonPositiveSignPos and Locale.loc_MonNegativeSignPos *)
  202.   parens *   = 0;     (* () surround the quantity and currency_symbol   *)
  203.   precAll *  = 1;     (* sign string comes before amount and symbol     *)
  204.   succAll *  = 2;     (* sign string comes after amount and symbol      *)
  205.   precCurr * = 3;     (* sign string comes right before currency symbol *)
  206.   succCurr * = 4;     (* sign string comes right after currency symbol  *)
  207.  
  208. (* constants for Locale.loc_MonPositiveCSPos and Locale.loc_MonNegativeCSPos *)
  209.   precedes * = 0;    (* currency symbol comes before value *)
  210.   succeeds * = 1;    (* currency symbol comes after value  *)
  211.  
  212. (* elements of the byte arrays pointed to by:
  213.  *   Locale.loc_Grouping
  214.  *   Locale.loc_FracGrouping
  215.  *   Locale.loc_MonGrouping
  216.  *   Locale.loc_MonFracGrouping
  217.  * are interpreted as follows:
  218.  *
  219.  *    255     indicates that no further grouping is to be performed
  220.  *    0       indicates that the previous element is to be repeatedly used
  221.  *            for the remainder of the digits
  222.  *    <other> the number of digits that comprises the current group
  223.  *)
  224.  
  225.  
  226. (*****************************************************************************)
  227.  
  228. CONST
  229.  
  230. (* Tags for OpenCatalog() *)
  231.   tagBase *         = u.user + 090000H;
  232.   builtInLanguage * = tagBase+1; (* language of built-in strings    *)
  233.   builtInCodeSet *  = tagBase+2; (* code set of built-in strings    *)
  234.   version *         = tagBase+3; (* catalog version number required *)
  235.   language *        = tagBase+4; (* preferred language of catalog   *)
  236.  
  237.  
  238. (*****************************************************************************)
  239.  
  240. CONST
  241.  
  242. (* Comparison types for StrnCmp() *)
  243.   ascii * = 0;
  244.   collate1 * = 1;
  245.   collate2 * = 2;
  246.  
  247.  
  248. (*****************************************************************************)
  249.  
  250. TYPE
  251.  
  252. (* This structure must only be allocated by locale.library and is READ-ONLY! *)
  253.   CatalogPtr * = POINTER TO Catalog;
  254.   Catalog * = RECORD (e.NodeBase)
  255.     link -     : e.Node;      (* for internal linkage    *)
  256.     pad -      : e.UWORD;     (* to longword align       *)
  257.     language - : e.LSTRPTR;    (* language of the catalog *)
  258.     codeSet -  : e.ULONG;     (* currently always 0      *)
  259.     version -  : e.UWORD;     (* version of the catalog  *)
  260.     revision - : e.UWORD;     (* revision of the catalog *)
  261.   END;
  262.  
  263.  
  264. (*-- Library Base variable --------------------------------------------*)
  265.  
  266. CONST
  267.  
  268.   localeName * = "locale.library";
  269.  
  270. VAR
  271.  
  272.   base* : LocaleBasePtr;
  273.  
  274.  
  275. (*-- Library Functions ------------------------------------------------*)
  276.  
  277. (*
  278. **      $VER: locale_protos.h 38.5 (18.6.93)
  279. *)
  280.  
  281. (*--- functions in V38 or higher (Release 2.1) ---*)
  282. PROCEDURE CloseCatalog* [base,-36]
  283.   ( catalog [8] : CatalogPtr );
  284.  
  285. PROCEDURE CloseLocale* [base,-42]
  286.   ( locale [8] : LocalePtr );
  287.  
  288. PROCEDURE ConvToLower* [base,-48]
  289.   ( locale    [8] : LocalePtr;
  290.     character [0] : CHAR )
  291.   : CHAR;
  292.  
  293. PROCEDURE ConvToUpper* [base,-54]
  294.   ( locale    [8] : LocalePtr;
  295.     character [0] : CHAR )
  296.   : CHAR;
  297.  
  298. PROCEDURE FormatDate* [base,-60]
  299.   ( locale       [8] : LocalePtr;
  300.     fmtTemplate  [9] : ARRAY OF CHAR;
  301.     VAR date    [10] : d.DateBase;
  302.     putCharFunc [11] : u.HookBasePtr );
  303.  
  304. PROCEDURE FormatString* [base,-66]
  305.   ( locale       [8] : LocalePtr;
  306.     fmtTemplate  [9] : ARRAY OF CHAR;
  307.     dataStream  [10] : e.APTR;
  308.     putCharFunc [11] : u.HookBasePtr )
  309.   : e.APTR;
  310.  
  311. PROCEDURE GetCatalogStr* [base,-72]
  312.   ( catalog       [8] : CatalogPtr;
  313.     stringNum     [0] : LONGINT;
  314.     defaultString [9] : ARRAY OF CHAR )
  315.   : e.LSTRPTR;
  316.  
  317. PROCEDURE GetLocaleStr* [base,-78]
  318.   ( locale    [8] : LocalePtr;
  319.     stringNum [0] : e.ULONG )
  320.   : e.LSTRPTR;
  321.  
  322. PROCEDURE IsAlNum* [base,-84]
  323.   ( locale    [8] : LocalePtr;
  324.     character [0] : CHAR )
  325.   : BOOLEAN;
  326.  
  327. PROCEDURE IsAlpha* [base,-90]
  328.   ( locale    [8] : LocalePtr;
  329.     character [0] : CHAR )
  330.   : BOOLEAN;
  331.  
  332. PROCEDURE IsCntrl* [base,-96]
  333.   ( locale    [8] : LocalePtr;
  334.     character [0] : CHAR )
  335.   : BOOLEAN;
  336.  
  337. PROCEDURE IsDigit* [base,-102]
  338.   ( locale    [8] : LocalePtr;
  339.     character [0] : CHAR )
  340.   : BOOLEAN;
  341.  
  342. PROCEDURE IsGraph* [base,-108]
  343.   ( locale    [8] : LocalePtr;
  344.     character [0] : CHAR )
  345.   : BOOLEAN;
  346.  
  347. PROCEDURE IsLower* [base,-114]
  348.   ( locale    [8] : LocalePtr;
  349.     character [0] : CHAR )
  350.   : BOOLEAN;
  351.  
  352. PROCEDURE IsPrint* [base,-120]
  353.   ( locale    [8] : LocalePtr;
  354.     character [0] : CHAR )
  355.   : BOOLEAN;
  356.  
  357. PROCEDURE IsPunct* [base,-126]
  358.   ( locale    [8] : LocalePtr;
  359.     character [0] : CHAR )
  360.   : BOOLEAN;
  361.  
  362. PROCEDURE IsSpace* [base,-132]
  363.   ( locale    [8] : LocalePtr;
  364.     character [0] : CHAR )
  365.   : BOOLEAN;
  366.  
  367. PROCEDURE IsUpper* [base,-138]
  368.   ( locale    [8] : LocalePtr;
  369.     character [0] : CHAR )
  370.   : BOOLEAN;
  371.  
  372. PROCEDURE IsXDigit* [base,-144]
  373.   ( locale    [8] : LocalePtr;
  374.     character [0] : CHAR )
  375.   : BOOLEAN;
  376.  
  377. PROCEDURE OpenCatalogA* [base,-150]
  378.   ( locale [8] : LocalePtr;
  379.     name   [9] : ARRAY OF CHAR;
  380.     tags  [10] : ARRAY OF u.TagItem )
  381.   : CatalogPtr;
  382.  
  383. PROCEDURE OpenCatalog* [base,-150]
  384.   ( locale [8]  : LocalePtr;
  385.     name   [9]  : ARRAY OF CHAR;
  386.     tags  [10]..: u.Tag )
  387.   : CatalogPtr;
  388.  
  389. PROCEDURE OpenLocale* [base,-156]
  390.   ( name [8] : ARRAY OF CHAR )
  391.   : LocalePtr;
  392.  
  393. PROCEDURE ParseDate* [base,-162]
  394.   ( locale       [8] : LocalePtr;
  395.     VAR date     [9] : d.DateBase;
  396.     fmtTemplate [10] : ARRAY OF CHAR;
  397.     getCharFunc [11] : u.HookBasePtr )
  398.   : BOOLEAN;
  399.  
  400. PROCEDURE StrConvert* [base,-174]
  401.   ( locale      [8] : LocalePtr;
  402.     string      [9] : ARRAY OF CHAR;
  403.     VAR buffer [10] : ARRAY OF CHAR;
  404.     bufferSize  [0] : e.ULONG;
  405.     type        [1] : e.ULONG )
  406.   : e.ULONG;
  407.  
  408. PROCEDURE StrnCmp* [base,-180]
  409.   ( locale   [8] : LocalePtr;
  410.     string1  [9] : ARRAY OF CHAR;
  411.     string2 [10] : ARRAY OF CHAR;
  412.     length   [0] : LONGINT;
  413.     type     [1] : e.ULONG )
  414.   : LONGINT;
  415.  
  416. (*-- Library Base variable --------------------------------------------*)
  417.  
  418. (*-----------------------------------*)
  419. PROCEDURE* [0] CloseLib (VAR rc : LONGINT);
  420.  
  421. BEGIN (* CloseLib *)
  422.   IF base # NIL THEN e.CloseLibrary (base) END
  423. END CloseLib;
  424.  
  425. BEGIN
  426.   base := SYS.VAL ( LocaleBasePtr,
  427.                     e.OpenLibrary (localeName, e.libraryMinimum));
  428.   IF base # NIL THEN Kernel.SetCleanup (CloseLib) END
  429. END Locale.
  430.